10. Min/Max Rescaler Coding Quiz

Min/Max Rescaler Coding Quiz

Question:

Start Quiz:

""" quiz materials for feature scaling clustering """

### FYI, the most straightforward implementation might 
### throw a divide-by-zero error, if the min and max
### values are the same
### but think about this for a second--that means that every
### data point has the same value for that feature!  
### why would you rescale it?  Or even use it at all?
def featureScaling(arr):

    return None

# tests of your feature scaler--line below is input data
data = [115, 140, 175]
print featureScaling(data)

Solution:

INSTRUCTOR NOTE:

Something to think about: What if x_max and x_min are the same? For example, suppose the list of input features is [10, 10, 10]--the denominator will be zero. Our suggestion would be in general to assign each new feature to 0.5 (halfway between 0.0 and 1.0), but it's really your call. The main point is that this exact formula can be broken.

The featureScaling procedure should return a list of rescaled values for all three values from the data list.